from selenium.webdriver.common.by import By
from common.Utils import BlogDriver

#博客首页测试用例
class BlogList:
    url=""
    driver=""
    def __init__(self):
        self.url="http://8.137.19.140:9090/blog_list.html"
        self.driver=BlogDriver.driver
        self.driver.get(self.url)
        #测试首页（登录情况下）
    def ListTestByLogin(self):
        #测试博客标题是否存在
        self.driver.find_element(By.CSS_SELECTOR,"body > div.container > div.right > div:nth-child(1) > div.title")
        # 测试博客时间是否存在
        self.driver.find_element(By.CSS_SELECTOR,"body > div.container > div.right > div:nth-child(1) > div.date")
        # 测试博客内容是否存在
        self.driver.find_element(By.CSS_SELECTOR,"body > div.container > div.right > div:nth-child(1) > div.desc")
        # 测试博客按钮是否存在
        self.driver.find_element(By.CSS_SELECTOR,"body > div.container > div.right > div:nth-child(1) > a")
        #个人信息-检查昵称是否存在
        self.driver.find_element(By.CSS_SELECTOR,"body > div.container > div.left > div > h3")
        # 点击⽂章
        self.driver.find_element(By.CSS_SELECTOR, "body > div.container > div.right > div:nth-child(1) > a").click()
        title = self.driver.title
        assert title == "博客详情页"
        #添加屏幕截图
        BlogDriver.getScreenShot()

